const { findAllPet, findOnePet } = require('../service/pet.service')
const { petGetListError } = require('../constant/err.type')

class PetController {
  // 查询所有数据
  async FindAll(ctx) {
    try {
      let res = await findAllPet()
      ctx.body = {
        code: 0,
        message: '获取宠物列表成功',
        result: res
      }
    }
    catch (err) {
      ctx.body = petGetListError
    }
  }
  async FindOne(ctx) {
    try {
      const id = ctx.request.params.id
      const res = await findOnePet(id)
      ctx.body = {
        code: 0,
        message: '获取数据成功',
        result: res[0]
      }
    }
    catch (err) {

    }
  }
}


module.exports = new PetController()